fix(discovery): check quota before upload (during discovery) - #9777
fix(discovery): check quota before upload (during discovery)#9777solracsf wants to merge 2 commits into
Conversation
114c6ee to
1f866cb
Compare
091d2a9 to
399b158
Compare
|
|
sorry for the mess |
399b158 to
e425898
Compare
e425898 to
dcb2b54
Compare
|
Artifact containing the AppImage: nextcloud-appimage-pr-9777.zip Digest: To test this change/fix you can download the above artifact file, unzip it, and run it. Please make sure to quit your existing Nextcloud app and backup your data. |
|
|
Every remaining SonarCloud issues are pre-existing code that SonarQube is classifying as "new" because our modifications shifted line numbers of otherwise untouched code into its diff window. The Quality Gate cannot be cleared by fixing code in this PR. |
Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>
c72a6c3 to
ef71e47
Compare
| void SyncEngine::slotInsufficientRemoteStorage() | ||
| { | ||
| auto msg = tr("There is insufficient space available on the server for some uploads."); | ||
| auto msg = tr("Upload paused: one or more files exceed your remaining Nextcloud storage quota. " |
There was a problem hiding this comment.
| auto msg = tr("Upload paused: one or more files exceed your remaining Nextcloud storage quota. " | |
| const auto msg = tr("Current files upload size exceeds your remaining storage quota." |
| { | ||
| auto msg = tr("There is insufficient space available on the server for some uploads."); | ||
| auto msg = tr("Upload paused: one or more files exceed your remaining Nextcloud storage quota. " | ||
| "Free up server space or contact your administrator to increase your quota."); |
There was a problem hiding this comment.
| "Free up server space or contact your administrator to increase your quota."); | |
| "Free up server space or contact your administrator to increase your user quota."); |
| emit propagator()->insufficientRemoteStorage(); | ||
| done(SyncFileItem::DetailError, tr("Upload of %1 exceeds the quota for the folder").arg(Utility::octetsToString(_fileToUpload._size))); | ||
| done(SyncFileItem::DetailError, | ||
| tr("Upload of %1 exceeds %2 of remaining storage quota for this folder") |
There was a problem hiding this comment.
| tr("Upload of %1 exceeds %2 of remaining storage quota for this folder") | |
| tr("Upload of %1 exceeds %2 of remaining storage quota for this folder.") |
| QCOMPARE(recordFolderA._folderQuota.bytesAvailable, 500); | ||
|
|
||
| // add fileNameA to folderA - size < quota in db | ||
| // ── Case 1: upload succeeds when size < fresh PROPFIND quota ── |
There was a problem hiding this comment.
| // ── Case 1: upload succeeds when size < fresh PROPFIND quota ── | |
| // Case 1: upload succeeds when size < fresh PROPFIND quota |
| // add smallFile to folderA - size < quota in db | ||
| const QString smallFile("A/smallFile.data"); | ||
| fakeFolder.localModifier().insert(smallFile, 100); | ||
| // ── Case 2: fresh PROPFIND value (0) wins over stale DB (500) ── |
There was a problem hiding this comment.
| // ── Case 2: fresh PROPFIND value (0) wins over stale DB (500) ── | |
| // Case 2: fresh PROPFIND value (0) wins over stale DB (500) |
| QCOMPARE(syncSpy.findItem(fileBlocked)->_status, SyncFileItem::Status::DetailError); | ||
|
|
||
| // create remoteFileA - size > bytes available | ||
| // ── Case 3: downloads are not affected by upload quota ── |
There was a problem hiding this comment.
| // ── Case 3: downloads are not affected by upload quota ── | |
| // Case 3: downloads are not affected by upload quota |
| fakeFolder.localModifier().insert(fileNameB, 0); | ||
|
|
||
| // set different quota for folderA - remote change does not change etag yet | ||
| // ── Case 4: after quota increase, previously blocked file uploads ── |
There was a problem hiding this comment.
| // ── Case 4: after quota increase, previously blocked file uploads ── | |
| // Case 4: after quota increase, previously blocked file uploads |
| QCOMPARE(syncSpy.findItem(fileNameD)->_status, SyncFileItem::Status::DetailError); | ||
|
|
||
| // create local fileNameE - size < quota in db | ||
| // ── Case 6: file within quota succeeds even while another is blocked ── |
There was a problem hiding this comment.
| // ── Case 6: file within quota succeeds even while another is blocked ── | |
| // Case 6: file within quota succeeds even while another is blocked |
|
This really needs to be tested with nextcloud/server#59398 merged. |
|




Fixes #4580 (more an enhancement of actual behavior)
Related to nextcloud/server#51977
Related to nextcloud/server#59398
Quota is now checked during discovery, before any data is transmitted. If a file exceeds available quota it receives a
DetailErrorimmediately, with no retry scheduled. A_quotaBytesReservedcounter prevents multiple files from being approved when their combined size exceeds quota.The propagator's pre-upload guard is also improved: it now walks the folder hierarchy to find the nearest quota entry, and the propagator is seeded with PROPFIND quota data at the start of each cycle. Combined with nextcloud/server#59398 and nextcloud/groupfolders#4539 this makes this behavior almost full proof.
4 new tests cover: single file blocked, unknown quota allowed, chunked upload blocked, and two files exceeding combined quota.